<?php
namespace app\portal\controller;
use cmf\controller\AdminBaseController;
class AdminMessageController extends AdminBaseController{
    //留言列表
    public function index(){
       $messages = db("message")->order("create_time desc")->paginate(15);
       $this->assign("messages",$messages);
       return $this->fetch();
    }
    
    /**
     * 处理留言，设置留言为已处理
     * @param unknown $id
     */
    public function dealMessage($id){
        $res = db("message")->where(['id'=>$id])->setField("status",1);
        if ($res){
            $this->success("处理成功！");
        }else{
            $this->error("处理失败！");
        }
    }
    /**
     * 删除留言
     */
    public function delete($id){
        $res = db("message")->delete($id);
        if ($res){
            $this->success("删除成功！");
        }else{
            $this->error("删除失败！");
        }
    }
    
}